#include <iostream>
#include <memory>
using namespace std;

// Product

class AbstractProduct
{
public:
    virtual ~AbstractProduct()
    {
    }
    virtual void Operation() = 0;
};

class ProductA : public AbstractProduct
{
public:
    void Operation() override
    {
        cout << "ProductA Operation" << endl;
    }
};

class ProductB : public AbstractProduct
{
public:
    void Operation() override
    {
        cout << "ProductB Operation" << endl;
    }
};

// Factory

class AbstractFactory
{
public:
    virtual ~AbstractFactory()
    {
    }
    virtual AbstractProduct *CreateProductA() = 0;
    virtual AbstractProduct *CreateProductB() = 0;
};

class ConcreteFactory : public AbstractFactory
{
public:
    AbstractProduct *CreateProductA() override
    {
        return new ProductA();
    }

    AbstractProduct *CreateProductB() override
    {
        return new ProductB();
    }
};

int main()
{
    std::unique_ptr<AbstractFactory> factory(
        std::make_unique<ConcreteFactory>());
    std::unique_ptr<AbstractProduct> productA(factory->CreateProductA());
    std::unique_ptr<AbstractProduct> productB(factory->CreateProductB());

    productA->Operation();
    productB->Operation();
    return 0;
}
